home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 7.5 KB | 261 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UMailableDocument.cp
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #if qPowerTalk
-
- #ifndef __UMAILABLEDOCUMENT__
- #include "UMailableDocument.h"
- #endif
-
- // MacApp
-
- #ifndef __UAPPLEEVENTS__
- #include "UAppleEvents.h"
- #endif
-
- // #ifndef __UAPPLICATION__
- // #include "UApplication.h"
- // #endif
-
- #ifndef __UDISPATCHER__
- #include "UDispatcher.h"
- #endif
-
- #ifndef __UFILE__
- #include "UFile.h"
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include "UMacAppGlobals.h"
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include "UMacAppUtilities.h"
- #endif
-
- #ifndef __UMAILER__
- #include "UMailer.h"
- #endif
-
- #ifndef __UWINDOW__
- #include "UWindow.h"
- #endif
-
- // Toolbox
-
- #ifndef __AEREGISTRY__
- #include <AERegistry.h>
- #endif
-
- #ifndef __OCEERRORS__
- #include <OCEErrors.h>
- #endif
-
- // ANSI
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- //========================================================================================
- // CLASS TMailableDocument
- //========================================================================================
- #undef Inherited
-
- #pragma segment MAOpen
- #define Inherited TFileBasedDocument
-
- MA_DEFINE_CLASS_M2(TMailableDocument, Inherited, MMailable);
-
- //----------------------------------------------------------------------------------------
- // MMailable constructor
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- TMailableDocument::TMailableDocument()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::IMailableDocument:
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- void TMailableDocument::IMailableDocument(TFile* itsFile, OSType itsScrapType)
- {
- this->IFileBasedDocument(itsFile, itsScrapType);
-
- // Have letters default to the same creator as the regular file.
- // We may be called with a null itsFile, in which case
- // IFileBasedDocument may make the file for us.
- if (!itsFile)
- itsFile = this->GetFile();
-
- if (itsFile)
- this->fMailCreator = itsFile->fCreator;
-
- } // TMailableDocument::IMailableDocument
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::Close:
- //----------------------------------------------------------------------------------------
- #pragma segment MARes
- void TMailableDocument::Close() // override
- {
-
- if (this->HasMailer())
- {
- TWindow* theWindowPtr = (TWindow *)fWindowList->First();
- WindowRef theWindow = theWindowPtr->fWMgrWindow;
- OSErr err = SMPPrepareToClose((WindowPtr)theWindow);
-
- if (err != noErr && err != kSMPNoMailerInWindow)
- {
- Failure(err,0);
- }
- }
-
- Inherited::Close();
-
- } // TMailableDocument::Close
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::Changed:
- //----------------------------------------------------------------------------------------
- #pragma segment MARes
- void TMailableDocument::Changed(ChangeID theChange,
- TObject* changedBy) // override
- {
- Inherited::Changed(theChange, changedBy);
- this->LetterContentChanged();
- } // TMailableDocument::Changed
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::DoMenuCommand:
- //----------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- void TMailableDocument::DoMenuCommand(CommandNumber aCommandNumber)
- {
- if (!this->DoMailMenuCommand(aCommandNumber))
- Inherited::DoMenuCommand(aCommandNumber);
- } // TMailableDocument::DoMenuCommand
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::DoSetupMenus:
- //----------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- void TMailableDocument::DoSetupMenus()
- {
- Inherited::DoSetupMenus();
- this->DoSetupMailMenus();
- } // TMailableDocument::DoSetupMenus
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::DoAECreateElement:
- //----------------------------------------------------------------------------------------
- #pragma segment MAScriptingRes
-
- void TMailableDocument::DoAECreateElement(TAppleEvent* message,
- TAppleEvent* reply)
- {
- DescType theClass = message->ReadType(keyAEObjectClass);
- if (theClass == cMailer)
- {
- if (!HasAOCEToolBox())
- FailOSErr(errAEEventNotHandled);
- this->DoAECreateMailer(message, reply);
- }
- else
- TFileBasedDocument::DoAECreateElement(message, reply);
- } // TMailableDocument::DoAECreateElement
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::CountContainedObjects:
- //----------------------------------------------------------------------------------------
- #pragma segment OSLDispatchRes
-
- long TMailableDocument::CountContainedObjects(DescType desiredType)
- {
- if (desiredType == cMailer)
- return this->CountContainedMailers();
- else
- return TFileBasedDocument::CountContainedObjects(desiredType);
- } // TMailableDocument::CountContainedObjects
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::GetIndContainedObject
- //----------------------------------------------------------------------------------------
- #pragma segment AMailerRes
-
- MScriptableObject* TMailableDocument::GetIndContainedObject(DescType desiredType,
- long index)
- {
- if (desiredType == cMailer)
- return this->GetIndContainedMailer(index);
- else
- return TFileBasedDocument::GetIndContainedObject(desiredType, index);
- } // TMailableDocument::GetIndContainedObject
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::DoScriptCommand
- //----------------------------------------------------------------------------------------
- #pragma segment AMailerRes
-
- void TMailableDocument::DoScriptCommand(CommandNumber aCommandNumber,
- TAppleEvent* message,
- TAppleEvent* reply)
- {
- switch (aCommandNumber)
- {
- case cAESend:
- this->DoAESend(message, reply);
- break;
-
- default:
- TFileBasedDocument::DoScriptCommand(aCommandNumber, message, reply);
- break;
- }
- } // TMailableDocument::DoScriptCommand
-
- //----------------------------------------------------------------------------------------
- // TMailableDocument::SaveDocument:
- //----------------------------------------------------------------------------------------
- #pragma segment MAWriteFile
-
- void TMailableDocument::SaveDocument(CommandNumber itsCommandNumber)// override
- {
- if (HasAOCEToolBox() && this->HasMailer())
- this->fLetter->SaveLetter(itsCommandNumber);
- else
- {
- TFile *theFile = this->fFile;
-
- Inherited::SaveDocument(itsCommandNumber);
-
- FInfo finderInfo;
- FXInfo xFinderInfo;
- Boolean isDirectory;
-
- OSErr theErr = theFile->GetFinderInfo(finderInfo, xFinderInfo, isDirectory);
- if (theErr == noErr && !isDirectory)
- {
- if (finderInfo.fdType == kStandardLetterFileType)
- {
- finderInfo.fdType = gDispatcher->fMainFileType;
- theFile->SetFinderInfo(finderInfo);
- }
- }
- }
- } // TMailableDocument::SaveDocument
-
- #endif // qPowerTalk
-
- //----------------------------------------------------------------------------------------
- // End of UMailableDocument.cp
-
- #pragma segment Inline
-